package tests.common.packets;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.ext.DefaultHandler2;

public class XMLTest {

	public static void main(String[] args) {
		
		InputStream in = XMLTest.class.getResourceAsStream("/tests/common/packets/test.xml");
		
		
		SAXParserFactory factory = SAXParserFactory.newInstance();
	
		factory.setValidating(false);
		
		try {
			SAXParser parser = factory.newSAXParser();
			
			
			parser.parse(in, new DefaultHandler2(){
				@Override
				public void startElement(String uri, String localName,
						String qName, Attributes attributes)
						throws SAXException {
//					super.startElement(uri, localName, qName, attributes);
					System.out.println(localName);
				}

				@Override
				public void endElement(String uri, String localName,
						String qName) throws SAXException {
					// TODO Auto-generated method stub
//					super.endElement(uri, localName, qName);
					System.out.println(localName);
				}
				
				@Override
				public void startEntity(String name) throws SAXException {
					// TODO Auto-generated method stub
					super.startEntity(name);
					System.out.println(name);
				}
				
				@Override
				public void startDocument() throws SAXException {
					// TODO Auto-generated method stub
					super.startDocument();
					System.out.println("start");
				}
				
			});
			

			
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
